
/*
* 注册小程序 app.js 调用 App()
*
* 注册页面 page-**.js 调用 Page()
* 页面中获取小程序实例 调用 getApp()
*
* */
import {PHONE} from '../../utils/tools'
const App = getApp()

Page({
  data: {
    msg: 'Hello WeApp!',
    textClass: 'green',
    count: 0,
    isShowMsg: true,
    list: [
      {message: '老刘',},
      {message: '张三',},
      {message: '李四',},
      {message: '王五'},
    ]
  },
  onTap() {
    // 0 1 2
    // this.count += 1
    const self = this
    // console.log(this.textClass)
    self.setData({
      count: self.data.count + 1
    })
    // ===
    switch (self.data.count % 3) {
      case 0:
        self.setData({textClass: 'white'})
        break
      case 1:
        self.setData({textClass: 'green'})
        break
      case 2:
        self.setData({textClass: 'blue'})
        break
    }
  },
  toggleMsg() {
    const self = this
    self.setData({
      isShowMsg: !self.data.isShowMsg
    })
    wx.navigateTo({
      url: '/pages/index/index'
      // url: '../../pages/index/index'
    })
  },
  onLoad() {
    console.log('=====')
    App.testAppFun()
    console.log(this)
    // console.log(getCurrentPages())
    console.log(PHONE)
  },
  onShow() {
    console.log('Page onShow')
  },
  onReady() {
    console.log('Page onReady')
  },
  onHide() {
    console.log('Page onHide')
  },
  onUnload() {
    console.log('Page onUnload')
  },
  onPullDownRefresh() {
    console.log('Page onPullDownRefresh')
  },
  onReachBottom() {
    console.log('Page onReachBottom')
  },
  onShareAppMessage() {
    console.log('Page onShareAppMessage')
    return {
      title: 'Test Share App Message',
      imageUrl: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png',
    }
  },
  onPageScroll(e) {
    console.log(e)
  },
  onResize() {
    console.log('onResize')
  },
})